{
  //声明类
  class Person {
    //属性
    name: string;
    age: number;

    //方法
    //构造器
    constructor(name: string, age: number) {
      this.name = name;
      this.age = age;
    }

    //声明一个方法, 在原型对象上添加方法
    intro() {
      console.log(`我叫 ${this.name} 今年 ${this.age}`);
    }

    //为实例对象添加方法
    intros = () => {};
  }

  //程序员的类
  class Programmer extends Person {
    //属性
    language: string;
    //构造器
    constructor(name: string, age: number, language: string) {
      super(name, age); // super 调用父类的构造方法
      this.language = language;
    }

    intro(): void {
      console.log(`我叫 ${this.name} ,今年 ${this.age}, 擅长 ${this.language}`);
    }
  }

  //实例化对象
  // let me = new Person('xiaohigh', 35);
  // //输出
  // console.log(me);
  // me.intro()

  //实例化 Programmer 类
  // let me = new Programmer('张三', 18, "JavaScript");
  // me.intro();

  //成员修饰符
  class Girl {
    public name: string;
    protected age: number;
    private weight: number;

    constructor(name: string, age: number, weight: number) {
      this.name = name;
      this.age = age;
      this.weight = weight;
    }

    test2(){
      console.log(this.name);// √ 
      console.log(this.age); // √
      console.log(this.weight); // √
    }
  }

  class Child extends Girl {
    test() {
      console.log(this.name);// √ 
      console.log(this.age); // √
      // console.log(this.weight); // X
    }
  }

  let yanqiu = new Girl("艳秋", 28, 120);

  console.log(yanqiu.name); // √
  // console.log(yanqiu.age);  // X
  // console.log(yanqiu.weight); // X
}
